{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Data as of</th>\n",
       "      <th>Start Week</th>\n",
       "      <th>End Week</th>\n",
       "      <th>State</th>\n",
       "      <th>Condition Group</th>\n",
       "      <th>Condition</th>\n",
       "      <th>ICD10_codes</th>\n",
       "      <th>Age Group</th>\n",
       "      <th>Number of COVID-19 Deaths</th>\n",
       "      <th>Flag</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>08/23/2020</td>\n",
       "      <td>02/01/2020</td>\n",
       "      <td>08/22/2020</td>\n",
       "      <td>US</td>\n",
       "      <td>Respiratory diseases</td>\n",
       "      <td>Influenza and pneumonia</td>\n",
       "      <td>J09-J18</td>\n",
       "      <td>0-24</td>\n",
       "      <td>102.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>08/23/2020</td>\n",
       "      <td>02/01/2020</td>\n",
       "      <td>08/22/2020</td>\n",
       "      <td>US</td>\n",
       "      <td>Respiratory diseases</td>\n",
       "      <td>Influenza and pneumonia</td>\n",
       "      <td>J09-J18</td>\n",
       "      <td>25-34</td>\n",
       "      <td>532.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>08/23/2020</td>\n",
       "      <td>02/01/2020</td>\n",
       "      <td>08/22/2020</td>\n",
       "      <td>US</td>\n",
       "      <td>Respiratory diseases</td>\n",
       "      <td>Influenza and pneumonia</td>\n",
       "      <td>J09-J18</td>\n",
       "      <td>35-44</td>\n",
       "      <td>1346.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>08/23/2020</td>\n",
       "      <td>02/01/2020</td>\n",
       "      <td>08/22/2020</td>\n",
       "      <td>US</td>\n",
       "      <td>Respiratory diseases</td>\n",
       "      <td>Influenza and pneumonia</td>\n",
       "      <td>J09-J18</td>\n",
       "      <td>45-54</td>\n",
       "      <td>3710.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>08/23/2020</td>\n",
       "      <td>02/01/2020</td>\n",
       "      <td>08/22/2020</td>\n",
       "      <td>US</td>\n",
       "      <td>Respiratory diseases</td>\n",
       "      <td>Influenza and pneumonia</td>\n",
       "      <td>J09-J18</td>\n",
       "      <td>55-64</td>\n",
       "      <td>8890.0</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Data as of  Start Week    End Week State       Condition Group  \\\n",
       "0  08/23/2020  02/01/2020  08/22/2020    US  Respiratory diseases   \n",
       "1  08/23/2020  02/01/2020  08/22/2020    US  Respiratory diseases   \n",
       "2  08/23/2020  02/01/2020  08/22/2020    US  Respiratory diseases   \n",
       "3  08/23/2020  02/01/2020  08/22/2020    US  Respiratory diseases   \n",
       "4  08/23/2020  02/01/2020  08/22/2020    US  Respiratory diseases   \n",
       "\n",
       "                 Condition ICD10_codes Age Group  Number of COVID-19 Deaths  \\\n",
       "0  Influenza and pneumonia     J09-J18      0-24                      102.0   \n",
       "1  Influenza and pneumonia     J09-J18     25-34                      532.0   \n",
       "2  Influenza and pneumonia     J09-J18     35-44                     1346.0   \n",
       "3  Influenza and pneumonia     J09-J18     45-54                     3710.0   \n",
       "4  Influenza and pneumonia     J09-J18     55-64                     8890.0   \n",
       "\n",
       "  Flag  \n",
       "0  NaN  \n",
       "1  NaN  \n",
       "2  NaN  \n",
       "3  NaN  \n",
       "4  NaN  "
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "df = pd.read_csv('../Conditions_contributing_to_deaths_involving_coronavirus_disease_2019__COVID-19___by_age_group_and_state__United_States..csv')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.rename({'Condition Group':'condgroup',\n",
    "           'Condition':'cond',\n",
    "           'Number of COVID-19 Deaths':'deaths'},\n",
    "          axis = 1, inplace = 1)\n",
    "small = df.groupby('cond').sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "deaths    0.265561\n",
       "dtype: float64"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "small.loc['COVID-19']/small.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
